$(()=>{
    let getUrl = enableStatic==="1"?"/getToolsList":"./?/getToolsList";
    $.get(getUrl,{},text=>{
        /*console.log(text);*/
        let card = 0;
        let titles = 0;
        let disabled=0;
        let data = JSON.parse(text);
        for (let i=0;i<data.length;i++){
            let t=``;
            if (data[i]["type"]==="card") {
                card++;
                if (!data[i]["api"]){
                    disabled++;
                }
                let link = "";
                if (data[i]["link"].substr(0,1)==="."){
                    link = data[i]["link"].replace("./?/","./?/doc/");
                }
                if (data[i]["link"].substr(0,1)==="/"){
                    link = "/doc"+data[i]["link"];
                }
                t = `<div class="col-lg-3 col-md-4 col-sm-6"><div class="card"><div class="card-main"><div class="card-inner"><p class="card-heading">${data[i]["title"]}</p><p>${data[i]["description"]}</p><p>`+(!data[i]["api"]?`<span class="fa fa-times text-red"></span><b class="text-red margin-left">不可用</b>`:`<span class="fa fa-check text-green"></span><b class="text-green margin-left">可用</b>`)+`</p></div><div class="card-action"><a class="btn btn-lg btn-flat waves-light waves-button waves-effect" href="`+(!data[i]["api"]?"javascript:alert('"+(data[i]["message"]||"API正在努力开发中，敬请期待！")+"');":`${link}`)+`">查看API文档</a></div></div></div></div>`;
            }else if(data[i]["type"]==="title"){
                titles++;
                t = `<div class="col-lg-12 col-md-12 col-sm-12 margin-no-top"><h2 class="content-sub-heading margin-no-top">${data[i]["title"]}</h2></div>`;
            }
            $("#tools").append(t);
            /*console.log(t);*/
        }
        $("#count").text(`共${card}个功能（${card-disabled}个功能可用），已完成${(((card-disabled)/card)*10000).toFixed()/100}%，${titles}个分类`);
        loadColor();
    });
});